/*
 * @Description: 
 * @Author: 张文韬
 * @Date: 2022-09-06 14:46:31
 * @LastEditTime: 2024-07-15 17:12:39
 * @LastEditors: 张文韬
 * @Reference: 
 */

import { 
  createInput, 
  createNumberInput,
  createSelect, 
  createDateSelect, 
  createTimeSelect,
  createReadonly,
  createSlot
} from "@/utils/e-components.tool"
import { dayjs } from "element-plus";

export const editFormRules = {
  product: [
    { required: true, message: '请选择产品', trigger: 'change' }
  ],
  insurancePeriod: [
    { required: true, message: '请选择保险期间', trigger: 'blur' }
  ],
  insuranceBeginDate: [
    { required: true, message: '请选择开始日期', trigger: 'change' }
  ],
  startTime: [
    { required: true, message: '请选择开始时间', trigger: 'change' }
  ],
  // insuranceEndDate: [
  //   { required: true, message: '请选择期满时间', trigger: 'change' }
  // ],
  addressInfo: [
    { required: true, message: '请选择目的地', trigger: 'change' }
  ],
};
 
const dateSelect = { type: 'date', valueFormat: 'YYYY-MM-DD',  clearable: false }

export const editFormOptions = [
  createSelect('产品选择', 'product')
    .setProps({'value-key': 'id'})
    .setChanged('product-change')
    .setSpan(12).option(),
  createNumberInput('保险期间', 'insurancePeriod')
    .setProps({clearable: false, max: 366})
    .setOnBlur('day-change')
    .setSpan(6).option(),
  createReadonly('标准', 'unitPrice').setSpan(3).option(),
  createReadonly('实收', 'discountPrice').setSpan(3).option(),
  createDateSelect('起保时间', 'insuranceBeginDate')
    .setChanged('start-change')
    .setProps({...dateSelect, disabledDate: (time) => time.getTime() <= dayjs().endOf('date').valueOf()})
    .setSpan(7).option(),
  createTimeSelect('', 'startTime',{labelWidth: '0px'})
    .setProps({type: 'time', format: 'HH:mm:ss', start: '00:00:00', end: '23:55:00', step: '00:05', clearable: false })
    .setChanged('time-change')
    .setSpan(5).option(),
  createDateSelect('期满时间', 'insuranceEndDate')
    .setChanged('end-change')
    .setProps({...dateSelect, format: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'YYYY-MM-DD HH:mm:ss'})
    .setSpan(12).option(),
  createSelect('目的地区', 'addressInfo').setProps({'value-key': 'id', multiple: true}).setSpan(10).option(),
  createSlot('', 'dest', {labelWidth: '0px'}).setSpan(2).option(),
  // createInput('团队编号', 'f').setSpan(12).option(),
  createSlot('投保须知', 'notice').setSpan(24).option()
]

